package com.github.binarywang.demo.wechat.controller;

import me.chanjar.weixin.common.bean.result.WxMediaUploadResult;
import me.chanjar.weixin.common.exception.WxErrorException;
import me.chanjar.weixin.mp.api.WxMpService;
import me.chanjar.weixin.mp.bean.WxMpMassTagMessage;
import me.chanjar.weixin.mp.bean.result.WxMpMassSendResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.File;

/**
 * Created by DELL on 2018/2/27.
 */
@RestController
@RequestMapping("/msg")
public class MessageController {


    @Autowired
    private WxMpService wxService;
    private final Logger logger = LoggerFactory.getLogger(this.getClass());


    @GetMapping("/sendall")
    public WxMpMassSendResult sendAll() throws WxErrorException {

        WxMpMassTagMessage message = new WxMpMassTagMessage();
        message.setMsgType("text");
        message.setContent("test send all");
        message.setSendAll(true);
        return wxService.getMassMessageService().massGroupMessageSend(message);
    }

}
